<template>
	<div class="container" id="outside">
		<iframe id="iframe"></iframe>
	</div>
</template>

<script>
var $iframe;
var vm;
export default {
	data: function() {
	    return {
	    }
	},
	methods : {
		loadPage : function() {
			//获取路径和校区id
			var path = vm.$route.path;
			var campusId = this.$store.state.campusId;
			//获取前缀通配,如果配置文件存在则转成实际前缀
			var prefix = vm.$store.state.permit[path];
			var base = process.env[prefix.toUpperCase()] || prefix;
			//延迟请求,防止参数变了没有刷新
			$iframe.attr("src", base + "/xxx");
			setTimeout(function() {
				$iframe.attr("src", base + path + "?campusId=" + campusId);
			},10);
			
		},
		campusChange : function() {
			vm.loadPage();
		}
	},
	watch:{
	  	$route(to,from){ //监听路由变化
	    	vm.loadPage();
	  	}
	},
	mounted : function() {
		$iframe = $("#iframe");
		vm.loadPage();
	},
	created : function() {
		vm = this;
	}
}
</script>

<style scoped>
	.container {
		height: 100%;
		font-size: 0;
	}
	#iframe {
		width: 100%;
		height: 100%;
		border: none;
		outline: 1px solid red;
	}
</style>